﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title>ChangePwd</title>
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
    function ChangePwd() {
        var oldPwd = $("#TB_OldPwd").val();
        var newPwd = $("#TB_Pwd").val();
        var reNewPwd = $("#tb_rePwd").val();
        if (oldPwd == "" || newPwd == "" || reNewPwd == "") {
            alert("请填写完整");
            return;
        }
        if (newPwd != reNewPwd) {
            alert("两次密码输入不相同");
            return;
        }
        if (newPwd == oldPwd) {
            alert("新密码不能与旧密码相同！");
            return;
        }
        $.ajax(
		{
		    url: "/Home/ChangeMyPwd",
		    data: { "oldPwd": oldPwd, "newPwd": newPwd },
		    success: function (data) {
		        if (data == true) {
		            alert("修改成功！");
		            document.location("BackMain");
		        }
		        else {
		            alert("修改失败！");
		            return;
		        }
		    },
		    error: function () {
		        alert("修改失败!");
		    }
		}
		);
    }
</script>
<body>
    <div>
        <div style="width: 100%; text-align: center; margin: auto;">
            <table style="margin-top: 200px; border: 0px solid Blue; text-align: center; border-collapse: collapse;" cellspacing="1" cellpadding="1" width="100%">
                <tr>
                    <td style="text-align: right; width: 50%">旧密码：</td>
                    <td style="text-align: left">
                        <input id="TB_OldPwd" type="password" name="name" value="admin" /></td>
                </tr>
                <tr>
                    <td style="text-align: right; width: 50%">新密码：</td>
                    <td style="text-align: left">
                        <input id="TB_Pwd" type="password" name="pwd" value="admin" /></td>
                </tr>
                <tr>
                    <td style="text-align: right; width: 50%">重复密码：</td>
                    <td style="text-align: left">
                        <input id="tb_rePwd" type="password" name="pwd" value="admin" /></td>
                </tr>
                <tr style="width: 100%">
                    <td colspan="2" style="text-align: center; margin: auto">
                        <br />
                        <input id="TB_Change" type="submit" name="TB_Change" value="修改密码" onclick="ChangePwd()" class="btn" /></td>
                </tr>
            </table>
        </div>
    </div>
</body>
</html>
